#include<stdio.h>

#define Min(a,b) (a) < (b) ? (a) : (b)

int MyStrlen(char*a)
{
    int count = 0;
    while(*a != '\0')
    {
        count++;
        a++;
    }
    return count;
}


int MyStrncmp(char *a,char*b,int n)
{
    n = Min(  Min ( MyStrlen(a) , MyStrlen(b) )  , n );

    while(*a == *b && n!=1 )
    {
        a++;
        b++;
        n--;
    }
    return *a-*b;

}



char* MyStrstr(char*a,char*b)
{
    int lena = MyStrlen(a);
    int lenb = MyStrlen(b);
    
    for(int i=0; i <= lena - lenb ; i++)
    {
        while( MyStrncmp(a+i,b,lenb)== 0 )
        {
            return a+i; 
        }
    }
    return NULL;

}



int main()
{
    char s1[] = "abcdefghi";
    char s2[] = "ef";


    printf("s2在s1中找到的是 %s\n",MyStrstr(s1,s2));
}